home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2004 April / Gamestar_61_2004-04_dvdb.iso / DVDStar / Editace / hltp.exe / {app} / Applications / QuArK / plugins / map1loadanymap.py < prev    next >
Text File  |  2004-01-05  |  4KB  |  137 lines

  1. """   QuArK  -  Quake Army Knife
  2.  
  3. Implementation of "Addons" menu Load Any Map function
  4. """
  5. #
  6. # Copyright (C) 1996-99 Armin Rigo
  7. # THIS FILE IS PROTECTED BY THE GNU GENERAL PUBLIC LICENCE
  8. # FOUND IN FILE "COPYING.TXT"
  9. #
  10.  
  11. #$Header: /cvsroot/quark/runtime/plugins/map1loadanymap.py,v 1.2 2003/12/18 21:51:46 peter-b Exp $
  12.  
  13. Info = {
  14.    "plug-in":       "Map1 Load Any Map",
  15.    "desc":          "This Item function allows you to load any map file and is located on the Addons menu>Other Programs category.",
  16.    "date":          "June 7 2003",
  17.    "author":        "cdunde, Decker and others",
  18.    "author e-mail": "cdunde1@attbi.com",
  19.    "quark":         "Version 6.4" }
  20.  
  21. import quarkpy.mapmenus
  22. from quarkpy.maputils import *
  23.  
  24.  
  25. class LoadMapDlg(quarkpy.qmacro.dialogbox):
  26.     #
  27.     # dialog layout
  28.     #
  29.  
  30.     endcolor = AQUA
  31.     size = (400,120)
  32.     dfsep = 0.35
  33.     flags = FWF_KEEPFOCUS
  34.     
  35.     dlgdef = """
  36.         {
  37.         Style = "9"
  38.         Caption = "LoadMap Dialog"
  39.  
  40.         loadmap: =
  41.         {
  42.         Txt = "Select a map file to load:"
  43.         Typ = "EP"
  44.         DefExt = "map"
  45.         BasePath = "$Game\\tmpQuArK\maps"
  46.         DirSep="/"
  47.         Hint = "Type in the name of the map file (.map file),"$0D
  48.                "preceded with its full path and forward slashes,"$0D
  49.                "(ex. C:/Quake2/tmpQuArK/maps/your.map),"$0D
  50.                "or just use the file browser ... to the right."$0D
  51.         }
  52.  
  53.         sep: = { Typ="S" Txt=" " }
  54.  
  55.         close:py = {Txt="" }
  56.         cancel:py = {Txt="" }
  57.  
  58.         }
  59.         """
  60.  
  61.     #
  62.     # __init__ initialize the object
  63.     #
  64.  
  65.     def __init__(self, form, editor, action):
  66.  
  67.     #
  68.     # General initialization of some local values
  69.     #
  70.  
  71.         self.editor = editor
  72.         src = quarkx.newobj(":")
  73.         self.src = src
  74.         self.action = action
  75.         self.form = form
  76.         self.src["loadmap"] = None
  77.  
  78.     #
  79.     # Create the dialog form and the buttons
  80.     #
  81.  
  82.         quarkpy.qmacro.dialogbox.__init__(self, form, src,
  83.         close = quarkpy.qtoolbar.button(
  84.             self.close,
  85.             "Load the selected map file",
  86.             ico_editor, 3,
  87.             "Load map file"),
  88.         cancel = quarkpy.qtoolbar.button(
  89.             self.cancel,
  90.             "Cancel & close window",
  91.             ico_editor, 0,
  92.             "Cancel"))
  93.  
  94.     def onclose(self, dlg):
  95.         if self.src is None:
  96.             qmacro.dialogbox.onclose(self, dlg)
  97.             return
  98.         quarkx.globalaccept()
  99.         self.action(self)
  100.         qmacro.dialogbox.onclose(self, dlg)
  101.  
  102.     def cancel(self, dlg):
  103.         self.src = None 
  104.         qmacro.dialogbox.close(self, dlg)
  105.  
  106. #        ********** FUNCTION Starts Here **********
  107.  
  108. def LoadMapClick(m):
  109.     def action(self):
  110.         if self.src["loadmap"] is None:
  111.             quarkx.msgbox("No map file entered, nothing done", MT_ERROR, MB_OK)
  112.             return
  113.  
  114.         editor = self.editor
  115.         tmpquark = self.src["loadmap"]
  116.         objfile = tmpquark.replace("/", "\\")
  117.         info = quarkx.openfileobj(objfile)
  118.         mygroup = quarkx.newobj('group:g')
  119.         mygroup.copyalldata(info.subitem(0))
  120.         quarkpy.mapbtns.dropitemsnow(editor, [mygroup], 'draw map')
  121.  
  122.     editor = mapeditor()
  123.     if editor is None: return
  124.     LoadMapDlg(quarkx.clickform,editor,action)
  125.  
  126.  
  127.  
  128. # ----------- REVISION HISTORY ------------
  129. #
  130. #$Log: map1loadanymap.py,v $
  131. #Revision 1.2  2003/12/18 21:51:46  peter-b
  132. #Removed reliance on external string library from Python scripts (second try ;-)
  133. #
  134. #Revision 1.1  2003/07/04 20:01:16  cdunde
  135. #To add new Addons main menu item and sub-menus
  136. #
  137.